package cn.kgc.kgceurekauserprovider.service;

import cn.kgc.pojo.User;
import org.springframework.web.bind.annotation.*;

/**
 * @author geQiang
 * @version 1.0
 * @date 2019/4/13
 * @description cn.kgc.kgceurekauserprovider.service
 */
@RestController
public class UserService {

    @RequestMapping("/login")
    public String login(
            @RequestParam(value = "username", defaultValue = "", required = false) String username,
            @RequestParam(value = "password", defaultValue = "", required = false) String password
    ) {
        System.out.println("我的端口:8083");
        if ("alen".equals(username) && "root".equals(password)) {
            return "alen:root";
        }
        return "sorry alen failed:8083!";
    }

    @RequestMapping(value = "/loginByUser", method = RequestMethod.POST)
    public User loginByUser(@RequestBody User user) {
        //Thread.sleep(5000);
        if ("alen".equals(user.getUsername()) && "root".equals(user.getPassword())) {
            user.setAddress("合肥科海");
            user.setAge(37);
            return user;
        }
        return user;
    }
}


